package com.leadingsoft.pwxk.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.leadingsoft.pwxk.dto.AreaDto;
import com.leadingsoft.pwxk.dto.RegionCodeDto;
import com.leadingsoft.pwxk.service.AreaService;
import com.leadingsoft.pwxk.service.BaseInfoService;
import com.leadingsoft.pwxk.service.RegionCodeService;

import io.swagger.annotations.ApiOperation;

/**
 * @author: lipan 2018年5月27日
 * @description: ( 码表 )
 * 
 */
@RestController
@RequestMapping("api/codes")
public class CodeController {

	@Autowired
	private RegionCodeService RegionCodeService;

	@Autowired
	private BaseInfoService baseInfoService;
	// 地区
	@Autowired
	private AreaService areaService;

	@GetMapping("reCode/{code}")
	RegionCodeDto get(@PathVariable(value = "code") String code) {
		return RegionCodeService.findByRegionCode(code);
	}

	@GetMapping("reParentCode/{code}")
	List<RegionCodeDto> findByparentCode(@PathVariable(value = "code") String code) {
		return RegionCodeService.findByparentCode(code);
	}

	@ApiOperation("行业类别")
	@GetMapping("trade/list")
	Map<String, String> findtrades() {
		return baseInfoService.getTrade();
	}

	@GetMapping("/area")
	@ApiOperation("地区-接口")
	@ResponseStatus(code = HttpStatus.OK)
	List<AreaDto> findAreaAll() {
		return areaService.getAll();
	}

	@GetMapping("/area/{areaId}")
	AreaDto findByAreaId(@PathVariable(value = "areaId") String areaId) {
		AreaDto dto = areaService.getByAreaId(areaId);
		return dto;
	}

	@ApiOperation("流域")
	@GetMapping("/basin")
	@ResponseStatus(code = HttpStatus.OK)
	public Map<String, String> getWsystem() {
		return baseInfoService.getWsystem();
	}

}
